<?php
namespace backend\models;
use yii\base\Model;

class PurchaseForm extends Model {
	
	/**
	 * 属性 
	 * @var unknown
	 */
	public $billcode;
	public $supplierid;
	public $operid;
 	public $merchandisename;
 	public $merchandiseid;
	public $num;
	public $price;	 
	public $intype;
	public $handler;
	public $totalmoney;
	public $remark;
	public $intime;
	
	public $id;
	public $suppliername;
	public $supplierab;
	public $address;
	public $linkname;
	public $linktel;
	public $qq;
	public $email;
	public $sortid;
	public $state;
	public $verycode;
	
	/**
	 * 规则(non-PHPdoc)
	 * @see \yii\base\Model::rules()
	 */
	public function rules(){
		return [
			//添加库存
			[['billcode','suppliername','merchandisename', 'intime','handler','intype','price','num'],'required','message'=>'该项不能为空','on'=>'addinfo'],
			[['billcode', 'handler','merchandiseid'], 'string', 'max' => 200,'tooLong'=>'不能超过20个字符','on'=>'addinfo'],
			//[['supplierid'], 'string', 'max' => 6,'tooLong'=>'不能超过6个字符','on'=>'add'],
			//['supplierid','unique','targetClass'=>TbaSupplierinfo::className(),'message'=>'该编号已存在','on'=>'addinfo'],
			[['num','price'],'integer','integerOnly'=>TRUE,'message'=>'必须是整型的数字','on'=>'addinfo'],
			[['remark'], 'string', 'max' => 150,'tooLong'=>'超过150个字符','on'=>'addinfo'],

			//添加供应商
			[['supplierid','suppliername','address'],'required','message'=>'该项不能为空','on'=>'addsupplier'],
			[['supplierid'], 'string', 'max' => 6,'tooLong'=>'不能超过6个字符'],
			['supplierid','unique','targetClass'=>TbaSupplierinfo::className(),'message'=>'该编号已存在','on'=>'addsupplier'],
			[['suppliername', 'linktel', 'qq', 'email'], 'string', 'max' => 50],
			['linktel','string','max'=>11,'min'=>8,'tooLong'=>'不能超过11个字符','tooShort'=>'不能少于8个字符','on'=>'addsupplier'],
			['qq','string','max'=>11,'min'=>'5','tooLong'=>'不能超过11个字符','tooShort'=>'不能少于5个字符','on'=>'addsupplier'],
			['email','email','message'=>'格式不正确','on'=>'addsupplier'],
			[['address'], 'string', 'max' => 200,'tooLong'=>'不能超过200个字符','on'=>'addsupplier'],
			[['sortid', 'state'], 'integer','message'=>'输入有误','on'=>'addsupplier'],
		];
	}
	
	/**
	 * 场景(non-PHPdoc)
	 * @see \yii\base\Model::scenarios()
	 */
	public function scenarios(){
		return [
			'addsupplier'=>['supplierid','suppliername','intime', 'supplierab','address','linkname','linktel','qq','email','sortid','state'],
			'addinfo'=>['billcode','merchandisename','intime','totalmoney', 'handler','intype','price','num', 'remark']
		];
	}
	
	/**
	 * 属性标签(non-PHPdoc)
	 * @see \yii\base\Model::attributeLabels()
	 */
	public function attributeLabels(){
		return [
			'billcode'=>'入库单号:',
			'supplierid'=>'供应商编号:',
			'operid'=>'操作员编码:',
		 	'merchandiseid'=>'商品编码:',
			'num'=>'数量:',
			'price'=>'进价:', 
			'intype'=>'入库方式:',
			'handler'=>'经手人:',
			'totalmoney'=>'总金额:',
			'remark'=>'备注:',
			'verycode'=>'验证码',
			'intime'=>'入库时间',
			
			'suppliername'=>'供应商名称',
			'supplierab'=>'供应商助记码',
			'merchandisename'=>'商品名称',
			'address'=>'地址',
			'linkname'=>'联系人姓名',
			'linktel'=>'联系人电话',
			'qq'=>'QQ',
			'email'=>'邮箱',
			'sortid'=>'排序编码',
			'state'=>'状态'
		];
	}
}
?>